// 基本关系图

export default function getBasicRelation(optionSet = []) {
  const graph = {
    links: [
      {
        source: '1',
        target: '0'
      },
      {
        source: '2',
        target: '0'
      },
      {
        source: '3',
        target: '0'
      },
      {
        source: '3',
        target: '2'
      },
      {
        source: '4',
        target: '0'
      },
      {
        source: '5',
        target: '0'
      },
      {
        source: '6',
        target: '0'
      },
      {
        source: '7',
        target: '0'
      },
      {
        source: '8',
        target: '0'
      },
      {
        source: '9',
        target: '0'
      },
      {
        source: '11',
        target: '0'
      },
      {
        source: '11',
        target: '2'
      },
      {
        source: '11',
        target: '3'
      },
      {
        source: '11',
        target: '10'
      },
      {
        source: '12',
        target: '11'
      }
    ],
    nodes: [
      {
        attributes: { modularityClass: 0 },
        category: 0,
        draggable: true,
        id: '0',
        itemStyle: null,
        name: 'Myriel',
        symbolSize: 10,
        value: 10,
        x: null,
        y: null
      },
      {
        attributes: { modularityClass: 0 },
        category: 0,
        draggable: true,
        id: '1',
        itemStyle: null,
        name: 'Napoleon',
        symbolSize: 10,
        value: 10,
        x: null,
        y: null
      },
      {
        attributes: { modularityClass: 1 },
        category: 0,
        draggable: true,
        id: '2',
        itemStyle: null,
        name: 'MlleBaptistine',
        symbolSize: 10,
        value: 10,
        x: null,
        y: null
      },
      {
        attributes: { modularityClass: 1 },
        category: 0,
        draggable: true,
        id: '3',
        itemStyle: null,
        name: 'MmeMagloire',
        symbolSize: 10,
        value: 10,
        x: null,
        y: null
      },
      {
        attributes: { modularityClass: 0 },
        category: 0,
        draggable: true,
        id: '4',
        itemStyle: null,
        name: 'CountessDeLo',
        symbolSize: 10,
        value: 10,
        x: null,
        y: null
      },
      {
        attributes: { modularityClass: 0 },
        category: 0,
        draggable: true,
        id: '5',
        itemStyle: null,
        name: 'Geborand',
        symbolSize: 10,
        value: 10,
        x: null,
        y: null
      },
      {
        attributes: { modularityClass: 0 },
        category: 0,
        draggable: true,
        id: '6',
        itemStyle: null,
        name: 'Geborand666',
        symbolSize: 10,
        value: 10,
        x: null,
        y: null
      },
      {
        attributes: { modularityClass: 0 },
        category: 0,
        draggable: true,
        id: '7',
        itemStyle: null,
        name: 'Geborand777',
        symbolSize: 10,
        value: 10,
        x: null,
        y: null
      },
      {
        attributes: { modularityClass: 0 },
        category: 0,
        draggable: true,
        id: '8',
        itemStyle: null,
        name: 'Geborand888',
        symbolSize: 10,
        value: 10,
        x: null,
        y: null
      },
      {
        attributes: { modularityClass: 0 },
        category: 0,
        draggable: true,
        id: '9',
        itemStyle: null,
        name: 'Geborand999',
        symbolSize: 10,
        value: 10,
        x: null,
        y: null
      },
      {
        attributes: { modularityClass: 1 },
        category: 1,
        draggable: true,
        id: '10',
        itemStyle: null,
        name: 'Geborand10',
        symbolSize: 10,
        value: 10,
        x: null,
        y: null
      },
      {
        attributes: { modularityClass: 1 },
        category: 1,
        draggable: true,
        id: '11',
        itemStyle: {
          color: 'yellow'
        },
        name: 'Geborand11',
        symbolSize: 10,
        value: 10,
        x: null,
        y: null
      },
      {
        attributes: { modularityClass: 1 },
        category: 1,
        draggable: true,
        id: '12',
        itemStyle: null,
        name: 'Geborand12',
        symbolSize: 10,
        value: 10,
        x: null,
        y: null
      }
    ]
  };
  const categories = [];
  for (let i = 0; i < 9; i++) {
    categories[i] = {
      name: '类目' + i
    };
  }

  graph.nodes.forEach(function(node) {
    node.itemStyle = null;
    node.symbolSize = 10;
    node.value = node.symbolSize;
    node.category = node.attributes.modularityClass;
    node.category = 0;
    // Use random x, y
    node.x = node.y = null;
    node.draggable = true;
  });
  graph.links.forEach((link, index) => {
    delete link.id;
    delete link.name;
    delete link.lineStyle;
  });

  const option = {
    title: {
      text: 'Les Miserables',
      subtext: 'Default layout',
      top: 'bottom',
      left: 'right'
    },
    tooltip: {},
    legend: [
      {
        // selectedMode: 'single',
        data: categories.map(function(a) {
          return a.name;
        })
      }
    ],
    animation: false,
    series: [
      {
        name: 'Les Miserables',
        type: 'graph',
        layout: 'force',
        data: graph.nodes,
        links: graph.links,
        categories: categories,
        roam: true,
        label: {
          normal: {
            position: 'right'
          }
        },
        force: {
          repulsion: 100
        }
      }
    ]
  };
  return option;
}
